const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}
const xiaoqu=n=>{
  var array = ["揽月山庄","林景雅园","明发云庭","明发悦庭"];
  return array;
}

const getdate = date => {
  var b = { weekText: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"], daysCount: 15, };
  var l = new Date();
  var o = [];
  var t = [];
  for (var k = 0; k < b.daysCount; k++) {
    var e = { key: String, value: String };
    var j = l.valueOf();
    j = j + k * 24 * 60 * 60 * 1000;
    j = new Date(j);
    var u = j.getFullYear();
    var g = j.getMonth() + 1;
    var r = j.getDate();
    var f = g + "月" + r + "日 " + b.weekText[j.getDay()];
    if (g <= 9) {
      g = "0" + g
    }
    if (r <= 9) {
      r = "0" + r
    }
    var q = u + "-" + g + "-" + r;
    e.key = q;
    if (k == 0) {
      f=f.substring(0,6) + "今天"
    } else if (k == 1) {
      f=f.substring(0, 6) + "明天"
    } else if (k == 2) {
      f=f.substring(0, 6) + "后天"
    }

    e.value = f;
    o.push(e);


  }
  for (var n = 5; n <= 23; n++) {
    var w = { key: String, value: String };
    if (n <= 9) {
      n = "0" + n
    }
    w.key = n + ":00", n + ":30";
    w.value = w.key;
    t.push(w);
  }
  var c = [];
  c.push(o);
  c.push(t);
  return c;
}

module.exports = {
  formatTime: formatTime,
  getdate:getdate,
  xiaoqu: xiaoqu
}
